package light.head.model;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import light.head.constant.Sys;

import org.hibernate.annotations.Formula;

/**
 * 文档信息
 *
 */
@Entity
@Table
public class DocumentInfo implements Serializable {
	

	private static final long serialVersionUID = -6668807475022230158L;
	
	
	private Integer code;
	private String name;					// 名称
	private Date ct = new Date();			// 上传时间
	private Byte pType = Sys.B_TWO;			// 公开权限（1、全部公开2、不公开3、指定机构 4、指定角色 5、指定用户）
	private Integer dc;						// 文档类别编号
	private Integer cu;						//上传者编号
	private String uuid;					// 路径
	private Boolean deleted = false;		// 是否删除
	private String ext;						// 后缀
	private Integer size;					//大小
	private Integer oc;						// 所属机构
	
	
	
	//Formula
	private String dn;									//文档类别名称
	private String cun;									//上传者姓名
	private List<Authority> publicList;		
	private List<DocumentInfo> list;
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column
	public Integer getCode() {
		return code;
	}
	
	@Column
	public String getName() {
		return name;
	}
	
	@Temporal(TemporalType.TIMESTAMP)
	@Column(updatable = false, nullable = false)
	public Date getCt() {
		return ct;
	}
	
	@Column
	public Integer getDc() {
		return dc;
	}
	
	@Column
	public String getUuid() {
		return uuid;
	}
	
	@Column
	public Boolean getDeleted() {
		return deleted;
	}
	
	@Column
	public Integer getCu() {
		return cu;
	}
	
	@Column
	public Byte getpType() {
		return pType;
	}
	
	@Column
	public String getExt() {
		return ext;
	}

	@Column
	public Integer getSize() {
		return size;
	}

	@Formula("(SELECT dt.name FROM DocumentType dt WHERE dt.code = dc)")
	public String getDn() {
		return dn;
	}
	
	@Transient
	public List<Authority> getPublicList() {
		return publicList;
	}

	@Formula("(SELECT u.realName FROM UserInfo u WHERE u.code = cu)")
	public String getCun() {
		return cun;
	}
	@Transient
	public List<DocumentInfo> getList() {
		return list;
	}

	@Column
	public Integer getOc() {
		return oc;
	}

	
	
	
	
	
	
	
	
	
	
	
	
	
	public void setOc(Integer oc) {
		this.oc = oc;
	}

	public void setList(List<DocumentInfo> list) {
		this.list = list;
	}

	public void setCu(Integer cu) {
		this.cu = cu;
	}

	public void setCun(String cun) {
		this.cun = cun;
	}

	public void setDn(String dn) {
		this.dn = dn;
	}
	
	public void setPublicList(List<Authority> publicList) {
		this.publicList = publicList;
	}

	public void setDc(Integer dc) {
		this.dc = dc;
	}
	public void setDeleted(Boolean deleted) {
		this.deleted = deleted;
	}
	public void setCode(Integer code) {
		this.code = code;
	}
	public void setName(String name) {
		this.name = name;
	}
	public void setCt(Date ct) {
		this.ct = ct;
	}
	public void setpType(Byte pType) {
		this.pType = pType;
	}
	public void setUuid(String uuid) {
		this.uuid = uuid;
	}

	public void setExt(String ext) {
		this.ext = ext;
	}

	public void setSize(Integer size) {
		this.size = size;
	}
	

}
